/*
 * @Description:流程说明书
 */
import { useBaseInfoWithOut } from '@/store/modules/base-info';
import globalData from '@/plugins/data';
import globalMethods from '@/plugins/methods';

const useBaseInfo = useBaseInfoWithOut();
/**
 * @description: 流程说明书
 * @param {Boolean} isOnlyBook 是否只展示流程说明书
 * @return {*}
 */
export function showHandbook(isOnlyBook) {
    // params = { id: 1 };
    // if (params.id == undefined) {
    //     return;
    // }
    const {
        template: { id: templateId },
        affair: { objectId },
    } = useBaseInfo.businessData;
    var url = isOnlyBook
        ? `${globalData.ctxPath}/template/template.do?method=templateProcessInstruction&templateId=${templateId}&needRead=1&objectId=${objectId}&moduleType=2`
        : `${globalData.ctxPath}/templateInsController.do?method=templateIns&id=${templateId}&showAll=1`;
    // if (params.showAll == '1') {
    //     url += '&showAll=1';
    // } else {
    //     if (params.form == '1') {
    //         url += '&form=1';
    //     } else {
    //         if (params.process == '1') {
    //             url += '&process=1';
    //         } else {
    //             if (params.ins == '1') {
    //                 url += '&ins=1';
    //             }
    //         }
    //     }
    // }
    const dialog = globalMethods.fullDialog({
        url,
        bodyStyle:'padding:0',
        title: this.$i18n('template.ins.title.js'),
        footer: null,
        onCancel() {
            dialog.close();
        },
    });
}

export default function (isOnlyBook) {
    return new Promise((resolve) => {
        showHandbook.call(this, isOnlyBook);
        resolve();
    });
}
